package com.retail.risk.analysis;

import java.time.LocalDate;
import java.util.List;

/**
 * 店铺销售风险分析测试类
 */
public class ShopRiskAnalysisTest {
    
    public static void main(String[] args) {
        ShopRiskAnalysisService service = new ShopRiskAnalysisService();
        
        // 设置分析日期
        LocalDate analysisDate = LocalDate.now();
        
        System.out.println("=== 店铺销售风险分析测试 ===");
        System.out.println("分析日期: " + analysisDate);
        System.out.println();
        
        // 1. 计算单个店铺风险评分
        System.out.println("1. 计算单个店铺风险评分");
        ShopRiskAnalysisService.RiskScoreResult result = service.calculateShopRiskScore(1, analysisDate);
        if (result != null) {
            System.out.println("店铺ID: " + result.getShopId());
            System.out.println("店铺名称: " + result.getShopName());
            System.out.println("风险评分: " + result.getTotalRiskScore());
            System.out.println("风险等级: " + result.getRiskLevel().getDescription());
            System.out.println("风险因素: " + result.getRiskFactors());
        }
        System.out.println();
        
        // 2. 获取高风险店铺列表
        System.out.println("2. 高风险店铺列表");
        List<ShopRiskAnalysisService.RiskScoreResult> highRiskShops = service.getHighRiskShops(analysisDate);
        for (ShopRiskAnalysisService.RiskScoreResult shop : highRiskShops) {
            System.out.println("店铺: " + shop.getShopName() + 
                             " | 风险评分: " + shop.getTotalRiskScore() + 
                             " | 等级: " + shop.getRiskLevel().getDescription());
        }
        System.out.println();
        
        // 3. 生成风险预警
        System.out.println("3. 生成风险预警");
        service.generateRiskAlerts(analysisDate);
        System.out.println("风险预警生成完成");
        System.out.println();
        
        // 4. 获取风险预警列表
        System.out.println("4. 风险预警列表");
        LocalDate startDate = analysisDate.minusDays(7);
        List<ShopRiskAnalysisService.RiskAlert> alerts = service.getRiskAlerts(startDate, analysisDate);
        for (ShopRiskAnalysisService.RiskAlert alert : alerts) {
            System.out.println("预警ID: " + alert.getAlertId() + 
                             " | 店铺: " + alert.getShopName() + 
                             " | 级别: " + alert.getAlertLevel() + 
                             " | 消息: " + alert.getAlertMessage());
        }
        System.out.println();
        
        // 5. 获取店铺销售趋势
        System.out.println("5. 店铺销售趋势分析");
        var trendData = service.getShopSalesTrend(1, 30);
        System.out.println("趋势数据获取完成，数据点数量: " + 
                         ((List<?>) trendData.get("dates")).size());
        
        System.out.println("\n=== 测试完成 ===");
    }
} 